/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.MainssupplyBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class MainssupplyDAO
/*     */ {
/*  21 */   private static final Log log = LogFactory.getLog(MainssupplyDAO.class);
/*  22 */   private dbConnector dbcon = null;
/*  23 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*  24 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*     */ 
/*     */   private void dbConInit() {
/*  27 */     if (this.dbcon == null)
/*  28 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  32 */     if (this.dbcon != null)
/*  33 */       this.dbcon.closeAll();
/*  34 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getMainsSupplyList(Map condition)
/*     */   {
/*  39 */     ListContentsBFO bfo = new ListContentsBFO();
/*  40 */     int start = Integer.parseInt(condition.get("start").toString());
/*  41 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  42 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  43 */     ResultSet rs = null;
/*  44 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  47 */       dbConInit();
/*  48 */       String strSQL = " select count(id) from mainssupply where btscode = '" + strBtscode + "' ";
/*  49 */       log.info(strSQL);
/*  50 */       rs = this.dbcon.execQuery(strSQL);
/*  51 */       if (rs.next()) {
/*  52 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  54 */       strSQL = " select * from mainssupply where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  55 */       log.info(strSQL);
/*  56 */       rs = this.dbcon.execQuery(strSQL);
/*  57 */       while (rs.next()) {
/*  58 */         MainssupplyBO bo = new MainssupplyBO();
/*  59 */         bo.setId(rs.getString("id"));
/*  60 */         bo.setBtscode(rs.getString("btscode"));
/*  61 */         bo.setBtsname(rs.getString("btsname"));
/*  62 */         bo.setType(rs.getString("type"));
/*  63 */         bo.setElecableTDLen(rs.getString("elecableTDLen"));
/*  64 */         bo.setElecableTDM(rs.getString("elecableTDM"));
/*  65 */         bo.setElecableTDT(rs.getString("elecableTDT"));
/*  66 */         bo.setElecableTDP(rs.getString("elecableTDP"));
/*  67 */         bo.setElecableLDLen(rs.getString("elecableLDLen"));
/*  68 */         bo.setElecableLDM(rs.getString("elecableLDM"));
/*  69 */         bo.setElecableLDT(rs.getString("elecableLDT"));
/*  70 */         bo.setElecableLDP(rs.getString("elecableLDP"));
/*  71 */         bo.setMaintenance(rs.getString("maintenance"));
/*  72 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  73 */         bo.setMemo(rs.getString("memo"));
/*  74 */         list.add(bo);
/*     */       }
/*  76 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  79 */       e.printStackTrace();
/*  80 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  83 */       dbConClose();
/*     */     }
/*  85 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveMainsSupplyBO(MainssupplyBO bo)
/*     */   {
/*  90 */     log.info("添加--市电引入---开始");
/*  91 */     boolean flag = true;
/*     */     try
/*     */     {
/*  94 */       dbConInit();
/*  95 */       StringBuffer sqlBuf = new StringBuffer();
/*  96 */       sqlBuf.append(" insert into mainssupply (btscode,  btsname, type, elecableTDLen,");
/*  97 */       sqlBuf.append(" elecableTDM, elecableTDT, elecableTDP, elecableLDLen, elecableLDM,");
/*  98 */       sqlBuf.append(" elecableLDT, elecableLDP, maintenance, refreshtime,registtime, memo  ) values ( ");
/*  99 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 100 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 101 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 102 */       sqlBuf.append(" '" + bo.getElecableTDLen() + "' ,");
/* 103 */       sqlBuf.append(" '" + bo.getElecableTDM() + "' ,");
/* 104 */       sqlBuf.append(" '" + bo.getElecableTDT() + "' ,");
/* 105 */       sqlBuf.append(" '" + bo.getElecableTDP() + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getElecableLDLen() + "' ,");
/* 107 */       sqlBuf.append(" '" + bo.getElecableLDM() + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getElecableLDT() + "' ,");
/* 109 */       sqlBuf.append(" '" + bo.getElecableLDP() + "' ,");
/* 110 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 111 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "', ");
/* 112 */       sqlBuf.append(" '" + this.open.format(new Date()) + "', ");
/* 113 */       sqlBuf.append(" '" + bo.getMemo() + "' )");
/* 114 */       log.info(sqlBuf.toString());
/* 115 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 119 */       flag = false;
/* 120 */       e.printStackTrace();
/* 121 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 124 */       dbConClose();
/*     */     }
/* 126 */     log.info("添加--市电引入---结束");
/* 127 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateMainsSupplyBO(MainssupplyBO bo)
/*     */   {
/* 133 */     log.info("修改--市电引入---开始");
/* 134 */     boolean flag = true;
/*     */     try
/*     */     {
/* 137 */       dbConInit();
/* 138 */       StringBuffer sqlBuf = new StringBuffer();
/* 139 */       sqlBuf.append(" update mainssupply set ");
/* 140 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 141 */       sqlBuf.append(" elecableTDLen = '" + bo.getElecableTDLen() + "' ,");
/* 142 */       sqlBuf.append(" elecableTDM = '" + bo.getElecableTDM() + "' ,");
/* 143 */       sqlBuf.append(" elecableTDT = '" + bo.getElecableTDT() + "' ,");
/* 144 */       sqlBuf.append(" elecableTDP = '" + bo.getElecableTDP() + "' ,");
/* 145 */       sqlBuf.append(" elecableLDLen = '" + bo.getElecableLDLen() + "' ,");
/* 146 */       sqlBuf.append(" elecableLDM = '" + bo.getElecableLDM() + "' ,");
/* 147 */       sqlBuf.append(" elecableLDT = '" + bo.getElecableLDT() + "' ,");
/* 148 */       sqlBuf.append(" elecableLDP = '" + bo.getElecableLDP() + "' ,");
/* 149 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 150 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "', ");
/* 151 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ");
/* 152 */       sqlBuf.append(" where id='" + bo.getId() + "'");
/* 153 */       log.info(sqlBuf.toString());
/* 154 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 158 */       flag = false;
/* 159 */       e.printStackTrace();
/* 160 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 163 */       dbConClose();
/*     */     }
/* 165 */     log.info("修改--市电引入---结束");
/* 166 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteMainsSupplyBO(String strID)
/*     */   {
/* 172 */     log.info("删除--市电引入---开始");
/* 173 */     boolean flag = true;
/*     */     try
/*     */     {
/* 176 */       dbConInit();
/* 177 */       StringBuffer sqlBuf = new StringBuffer();
/* 178 */       sqlBuf.append(" delete from mainssupply  ");
/* 179 */       sqlBuf.append(" where id='" + strID + "'");
/* 180 */       log.info(sqlBuf.toString());
/* 181 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 185 */       flag = false;
/* 186 */       e.printStackTrace();
/* 187 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 190 */       dbConClose();
/*     */     }
/* 192 */     log.info("删除--市电引入---结束");
/* 193 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getMainsSupplyByBtsName(Map condition)
/*     */   {
/* 198 */     ListContentsBFO bfo = new ListContentsBFO();
/* 199 */     int start = Integer.parseInt(condition.get("start").toString());
/* 200 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 201 */     String strBtsName = condition.get("btsName").toString();
/* 202 */     ResultSet rs = null;
/* 203 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 206 */       dbConInit();
/*     */ 
/* 208 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 209 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 211 */       String strSQL = " select count(id) from mainssupply where btsname like '%" + strBtsName + "%' ";
/* 212 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 213 */       log.info(strSQL);
/* 214 */       rs = this.dbcon.execQuery(strSQL);
/* 215 */       if (rs.next()) {
/* 216 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 218 */       strSQL = " select * from mainssupply where btsname like '%" + strBtsName + "%' ";
/* 219 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 220 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 221 */       log.info(strSQL);
/* 222 */       rs = this.dbcon.execQuery(strSQL);
/* 223 */       while (rs.next()) {
/* 224 */         MainssupplyBO bo = new MainssupplyBO();
/* 225 */         bo.setId(rs.getString("id"));
/* 226 */         bo.setBtscode(rs.getString("btscode"));
/* 227 */         bo.setBtsname(rs.getString("btsname"));
/* 228 */         bo.setType(rs.getString("type"));
/* 229 */         bo.setElecableTDLen(rs.getString("elecableTDLen"));
/* 230 */         bo.setElecableTDM(rs.getString("elecableTDM"));
/* 231 */         bo.setElecableTDT(rs.getString("elecableTDT"));
/* 232 */         bo.setElecableTDP(rs.getString("elecableTDP"));
/* 233 */         bo.setElecableLDLen(rs.getString("elecableLDLen"));
/* 234 */         bo.setElecableLDM(rs.getString("elecableLDM"));
/* 235 */         bo.setElecableLDT(rs.getString("elecableLDT"));
/* 236 */         bo.setElecableLDP(rs.getString("elecableLDP"));
/* 237 */         bo.setMaintenance(rs.getString("maintenance"));
/* 238 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 239 */         bo.setMemo(rs.getString("memo"));
/* 240 */         list.add(bo);
/*     */       }
/* 242 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 245 */       e.printStackTrace();
/* 246 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 249 */       dbConClose();
/*     */     }
/* 251 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 257 */     ResultSet rs = null;
/* 258 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 261 */       dbConInit();
/* 262 */       String strSQL = " select * from mainssupply where btsname like '%" + strBtsName + "%'   ";
/* 263 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 264 */       log.info(strSQL);
/* 265 */       rs = this.dbcon.execQuery(strSQL);
/* 266 */       while (rs.next()) {
/* 267 */         MainssupplyBO bo = new MainssupplyBO();
/* 268 */         bo.setId(rs.getString("id"));
/* 269 */         bo.setBtscode(rs.getString("btscode"));
/* 270 */         bo.setBtsname(rs.getString("btsname"));
/* 271 */         bo.setType(rs.getString("type"));
/* 272 */         bo.setElecableTDLen(rs.getString("elecableTDLen"));
/* 273 */         bo.setElecableTDM(rs.getString("elecableTDM"));
/* 274 */         bo.setElecableTDT(rs.getString("elecableTDT"));
/* 275 */         bo.setElecableTDP(rs.getString("elecableTDP"));
/* 276 */         bo.setElecableLDLen(rs.getString("elecableLDLen"));
/* 277 */         bo.setElecableLDM(rs.getString("elecableLDM"));
/* 278 */         bo.setElecableLDT(rs.getString("elecableLDT"));
/* 279 */         bo.setElecableLDP(rs.getString("elecableLDP"));
/* 280 */         bo.setMaintenance(rs.getString("maintenance"));
/* 281 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 282 */         bo.setMemo(rs.getString("memo"));
/* 283 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 287 */       e.printStackTrace();
/* 288 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 291 */       dbConClose();
/*     */     }
/* 293 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.MainssupplyDAO
 * JD-Core Version:    0.6.2
 */